<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*,util.*,dal.*,model.*,bll.*"%>
<%
	PlaceModel obj;
	Object temp = request.getAttribute("place");
	if (temp != null) {
		try {
			obj = (PlaceModel) temp;
		} catch (Exception ex) {
			obj = new PlaceModel();
		}
	} else {
		obj = new PlaceModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Edit Place</title>
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/inputForm.css" />
<link rel="stylesheet" href="css/listForm.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
<link rel="stylesheet" href="css/themes/ui-lightness/jquery.ui.all.css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css" type="text/css" />
<link rel="stylesheet" href="css/jquery-datepicker.css" />
<link rel="stylesheet" href="css/jquery-dialog.css" />

<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxQuickInsert.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.numeric.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.tools.min.js"></script>

<script language="javascript" type="text/javascript">

$(document).ready(pageLoaded);

function pageLoaded()
{
	turnOnNumbericInput();
	initTooltip();	
} 
	var requiredInputs = [['name','name_required']];
	var intInputs = [];
	var doubleInputs = [];
	var dateInputs = [];
	var timeInputs = [];
	

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
	
	
</script>
</head>
<body>
	<div class="divContainer">
		<%@ include file="menu.jsp"%>
				<form id="inputForm" action="place?mode=update" method="post" onSubmit="return checkInputs()">
					<table class="tblInput">
						<tr>
							<td class="inputHeader">EDIT PLACE INFO</td>
						</tr>
							<tr>
					<td style="padding-left: 400px; padding-right: 400px;">
						<table cellspacing="0px">
						<tr class="trField">
							<td class="tdFieldName">Id</td>
							<td class="tdFieldInput">
								<input class="inputInt readonly" type="text" id="id" name="id" readonly="readonly" value="<%=obj.getId()%>" title="Id of this place. Note: Can not edit"/>
								<span class="textGuide"> (Can not edit)</span>
							</td>
							<td class="tdErrMsg"></td>
						</tr>
						
						
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="name" name="name" maxlength="255" value="<%=obj.getNameToString()%>" title="Change name of this place." onblur="validateRequiredInput('name');" />
							</td>
							<td class="tdErrMsg">
								<span id="name_required" class="errMsg" style="display: none;" title="Name is required">(!)</span> 
								<span id="name_error" class="errMsg" title="<%=obj.errMsgs.Name%>"></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Code</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCodeToString() %>" title="Code of new place." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Description</td>
							<td class="tdFieldInput">
								<textarea id="description" name="description" rows="5" class="inputTextarea" title="Edit description for this place."><%=obj.getDescriptionToString() %></textarea>
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
						<td class="tdFieldName">Type</td>
						<td class="tdFieldInput">
							<select id="id_type" name="id_type" class="hyjack" title="Choose a type for this place.">
								<%=HtmlUtil.<PlaceTypeModel>genModelSelect(CacheUtil.getPlaceTypeList(), null,obj.getIdType())%>
							</select>
							<input class="btnAdd" type="button" id="addNewIdType" value="" onclick="ajaxAddItem('#id_type', 'placeType', 'name', 'Please enter new place type name!');" title="Click here to add new place type."/>
						</td>
						<td class="tdErrMsg">
						</td>
					</tr>	
						<tr class="trInputBottom">
							<td class="tdFieldName"></td>
							<td class="tdSubmit"><input class="btnSubmit" type="submit" value="Submit" title="Click to save above information."/></td>

						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	<%
	
		String urlPlaceList = "placeList.jsp?embedded=true";
	%>
		<jsp:include page='<%=urlPlaceList%>'></jsp:include>
	</div>
</body>
</html>